package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.dto.ReplyDTO;
import com.tianji.learning.entity.InteractionQuestion;
import com.tianji.learning.entity.InteractionReply;
import com.tianji.learning.query.ReplyPageQuery;
import com.tianji.learning.service.IInteractionQuestionService;
import com.tianji.learning.service.IInteractionReplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 互动问题的回答或评论--管理端
 * </p>
 *
 * @author author
 * @since 2023-05-29
 */
@RestController
@Api("互动问题的回答或评论")
@RequestMapping("/admin/replies")
@RequiredArgsConstructor
@Slf4j
public class InteractionReplyAdminController {

    private final IInteractionQuestionService questionService;
    private final IInteractionReplyService replyService;

    @ApiOperation("分页查询互动问题的回答或评论")
    @GetMapping("/page")
    public PageDTO<ReplyDTO> queryQuestionAdminPage(ReplyPageQuery query){
        return replyService.queryQuestionAdminPage(query);
    }

    @ApiOperation("隐藏问题")
    @PutMapping("/{id}/hidden/{hidden}")
    public void updateQuestion(@PathVariable("id") Long id, @PathVariable("hidden") Boolean hidden){
        log.info("是否隐藏提问：{}",hidden);
        replyService.lambdaUpdate()
                .set(InteractionReply::getHidden,hidden)
                .eq(InteractionReply::getId,id)
                .update();
    }



}
